<include file="Public/header"/>
<include file="Public/menu"/>
<script src="/Public/layer/layer.js"></script>
<style type="text/css">
    .yellowtop {
        background-color: #ffffcc;
    }

    .graytop {

        text-align: center;
    }

    .blank {
        width: 100%;
        height: 50px;
        background: #eee;
    }
    .box-header h1{
        text-align: center !important;
        font-size: 25px !important;
    }
    .message{
        border-bottom: 1px #ccc solid;word-break: break-all;
    }
    .fontsize20 {
        font-size: 20px;
        color: red;
    }
</style>
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            首页
            <small>结算</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">店铺结算账单</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">
        <div class="tab-content">
            <div class="tab-pane active" id="tab_0">
                <div class="box">
                    <div class="box-header">
                        <h1 class="box-title">结算单</h1>
                        <div class="">
                            <div class="btn-group pull-left" style="text-align: left;">
                                结算对象： 怡臣电子商务集团有限公司
                                <br>
                                结算时间：{$info.start_time|date='Y-m-d H:i',###} - <?php echo date('Y-m-d H:i', ($info['end_time'] + 86399))?>
                            </div>
                            <div class="btn-group pull-right" style="margin-right: 10px">
                                结算单号：{$info.account_id}
                            </div>
                        </div>

                    </div>
                    <div class="box-header">
                        <div class="btn-group pull-right" style="margin-right: 10px">
                            <a href="{:U('exportExcel',array('id'=>$_GET['id']))}" class="btn btn-sm btn-success"><i class="fa fa-save"></i>&nbsp;&nbsp;导出EXCEL</a>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover table-bordered">
                            <tbody>
                            <tr>
                                <td colspan="10" class="yellowtop">结算明细</td>
                            </tr>
                            <tr>
                                <th>序</th>
                                <th>订单号</th>
                                <th>商品</th>
                                <th>佣金率</th>
                                <th>佣金金额</th>
                                <th>店铺优惠</th>
                                <th>订单金额</th>
                                <th>实支付金额</th>
                                <th>支付日期</th>
                                <th>支付方式</th>
                                <!--<th>线上手续费</th>-->
                            </tr>
                            <volist name="order" id="vo" key="key">
                                <tr>
                                    <td>{$key}</td>
                                    <td>{$vo.order_id}</td>
                                    <input type="hidden" name="order[]" value="{$vo.order_id}">
                                    <if condition="$vo['geshu'] gt 1">
                                        <td>
                                            <table>
                                                <volist name="vo['list']" id="v">
                                                    <tr>
                                                        <td>{$v.name}</td>
                                                    </tr>
                                                </volist>
                                            </table>
                                        </td>
                                        <td>
                                            <table>
                                                <volist name="vo['list']" id="v">
                                                    <tr>
                                                        <td>{$v.yc_rate}%</td>
                                                    </tr>
                                                </volist>
                                            </table>
                                        </td>
                                        <td>
                                            <table>
                                                <volist name="vo['list']" id="v">
                                                    <tr>
                                                        <td class="yc_fee">{$v.yc_fee}</td>
                                                    </tr>
                                                </volist>
                                            </table>
                                        </td>
                                        <td>
                                            <table>
                                                <volist name="vo['list']" id="v">
                                                    <tr>
                                                        <td class="youhi">{$v.youhui}</td>
                                                    </tr>
                                                </volist>
                                            </table>
                                        </td>
                                        <else/>
                                        <td>{$vo['list'][0]['name']}</td>
                                        <td>{$vo['list'][0]['yc_rate']}%</td>
                                        <td class="yc_fee">{$vo['list'][0]['yc_fee']}</td>
                                        <td class="youhi">{$vo['list'][0]['youhui']}</td>
                                    </if>
                                    <!--<td>{$vo.cost_freight}</td>-->
                                    <td>{$vo.cost_item}</td>
                                    <td>{$vo['total_amount']}</td>
                                    <td>{$vo.createtime|date='Y-m-d H:i:s', ###}</td>
                                    <td>{$vo.paymethod_name|default='-'}</td>
                                </tr>
                            </volist>
                            <tr>
                                <td colspan="10" class="graytop">共计</td>
                            </tr>
                            <tr>
                                <th>订单数量</th>
                                <th>订单支付总金额</th>
                                <th>店铺总优惠</th>
                                <th>抽佣总额</th>
                                <th>银行转账手续费</th>
                                <th>其他</th>
                                <th>应结算总金额</th>
                            </tr>
                            <tr>
                                <td>{$info.order_num}</td>
                                <td>{$info.order_totalPrice}</td>
                                <td>{$info.youhui}</td>
                                <td>{$info.order_commission}</td>
                                <td>{$info.order_bank}</td>
                                <td>{$info.order_other}</td>
                                <td>{$info.order_finalPirce}</td>
                            </tr>
                            </tbody>
                        </table>
                        <div class="blank"></div>
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover table-bordered">
                                <tbody>
                                <tr>
                                    <td colspan="10" class="yellowtop">退款明细</td>
                                </tr>
                                <tr>
                                    <th>ID</th>
                                    <th>订单号</th>
                                    <th>商品</th>
                                    <th>佣金率</th>
                                    <th>抽佣金额</th>
                                    <th>退款金额</th>
                                    <th>退款完成日期</th>
                                    <th>店铺经办</th>
                                    <th>退款经办</th>
                                </tr>
                                <volist name="refund" id="vo" key="key">
                                    <tr>
                                        <td>{$key}</td>
                                        <input type="hidden" name="refund[]" value="{$vo.order_id}">
                                        <td>{$vo.order_id}</td>
                                        <if condition="$vo['geshu'] gt 1">
                                            <td>
                                                <table>
                                                    <volist name="vo['list']" id="v">
                                                        <tr>
                                                            <td>{$v.name}</td>
                                                        </tr>
                                                    </volist>
                                                </table>
                                            </td>
                                            <td>
                                                <table>
                                                    <volist name="vo['list']" id="v">
                                                        <tr>
                                                            <td>{$v.yc_rate}%</td>
                                                        </tr>
                                                    </volist>
                                                </table>
                                            </td>
                                            <td>
                                                <table>
                                                    <volist name="vo['list']" id="v">
                                                        <tr>
                                                            <td>{$v.yc_fee}</td>
                                                        </tr>
                                                    </volist>
                                                </table>
                                            </td>
                                            <else/>
                                            <td>{$vo['list'][0]['name']}</td>
                                            <td>{$vo['list'][0]['yc_rate']}%</td>
                                            <td>{$vo['list'][0]['yc_fee']}</td>
                                        </if>
                                        <td class="price_detail" data-yongjin="{$vo.yongjin|default=0}">
                                            {$vo.price_detail}
                                        </td>
                                        <td>{$vo.finance_confirm_t|date='Y-m-d H:i:s', ###}</td>
                                        <td>{$vo.store_name}</td>
                                        <td>{$vo.finance_name}</td>
                                    </tr>
                                </volist>
                                <tr>
                                    <td colspan="10" class="graytop">共计</td>
                                </tr>
                                <tr>
                                    <th>订单数量</th>
                                    <th>订单退款总金额</th>
                                    <th>返还抽佣总额</th>
                                    <th>其他</th>
                                    <th>应结算总金额</th>
                                </tr>
                                <tr>
                                    <td>{$info.refund_num}</td>
                                    <td>{$info.refund_totalPrice}</td>
                                    <td>{$info.refund_commission}</td>
                                    <td>{$info.refund_other}</td>
                                    <td>{$info.refund_finalPrice}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="blank"></div>
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover table-bordered">
                                <tbody>
                                <tr>
                                    <td colspan="10" class="yellowtop">合计</td>
                                </tr>
                                <tr>
                                    <th>应结算总金额</th>
                                    <th>退款扣除总金额</th>
                                    <th>实际结算金额</th>
                                </tr>
                                <tr>
                                    <td>{$info.order_finalPirce}</td>
                                    <td>{$info.refund_finalPrice}</td>
                                    <td>￥<span class="badge bg-red fontsize20">{$info.final_accountMoney}</span></td>
                                </tr>
                                <tr>
                                    <td colspan="10">经办人：{$info.handle_name}</td>

                                </tr>
                                <tr>
                                    <td colspan="10">
                                        备注: {$info.remark}
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="blank"></div>
                        <if condition="$info['money_img'] neq ''">
                            <div class="box-body table-responsive no-padding">
                                <div class="yellowtop" style="padding: 8px;">付款信息</div>
                                <div style="text-align: center;width: 40%">
                                    <img src="/Uploads/{$info['money_img']}" alt="" style="width: 100%">
                                </div>
                            </div>
                        </if>
                        <div class="box-footer clearfix">
                            <if condition="$info['state'] eq 0">
                            <a class="btn btn-sm btn-success queren" data-id="{$_GET['id']}" data-state="1">对账确认</a>
                            <a class="btn btn-sm btn-danger yc-yy-operate" data-id="{$_GET['id']}">提出异议</a>
                            <elseif condition="$info['state'] eq 2" />
                            <a class="btn btn-sm btn-primary yc-yy-operate" data-id="{$_GET['id']}" data-state="1">异议处理中</a>
                            <else />
                            <a class="btn btn-sm btn-success" data-id="{$_GET['id']}" data-state="1">交易成功</a>
                            </if>
                        </div>
                    </div>
                </div>

            </div>
    </section>
</div>
<div class="modal fade" id="myYYModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">
                    结算异议
                </h4>
            </div>
            <form role="form" id="yy-form-mark" onSubmit="return false;">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <div>
                                    <label>备注</label>
                                    <textarea class="form-control" rows="2" id="yy_desc" placeholder="添加备注" name="desc"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div>
                                    <label for="">异议联系人</label>
                                    <input id="yy_name" type="text" class="form-control" name="name" value="">
                                </div>
                            </div>
                            <div class="form-group">
                                <div>
                                    <label>联系电话</label>
                                    <input id="yy_tel" type="text" class="form-control" name="tel" value="">
                                    <input id="yy_id" type="hidden" name="id" value="{$_GET['id']}">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6" style="height: 240px;overflow-y: scroll;overflow-x: hidden;">
                            <div class="form-group">
                                <label>反馈区</label>
                                <div id="commentarea"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="submit" class="btn btn-primary">
                        提交
                    </button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 底部 -->
<include file="Public/common_footer"/>
<script type="text/javascript" src="/Public/admin/js/com.bill.yy.js"></script>
<script type="text/javascript">
	yc_yy_url = "{:U('Bills/sendyiyi')}"; 
	$('.queren').on('click', function () {
		var id = $(this).data('id');
		var state = $(this).data('state');
		$.post("{:U('changeStatus')}", {id:id, state:state}, function (res) {
			if (res.status) {
				alert(res.message);
				window.location.reload();
			}
		});
	});       
	var list = <php> echo $info['talk'] ? $info['talk'] : "''";</php>;
	renderYYList(list);
</script>